<?php

/*
 * Copyright (C) 2014 vlasta81
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

define('DEVELOP', TRUE);
define('SECURE', 'XLKDZJRKWOSLCMG');
define('DS', DIRECTORY_SEPARATOR);
define('PS', PATH_SEPARATOR);
define('CHARSET', 'utf8');
define('BASE_PATH', __DIR__);
define('WWW_PATH', 'http://' . filter_input(INPUT_SERVER, 'HTTP_HOST', FILTER_SANITIZE_URL));

set_include_path(BASE_PATH . PS . get_include_path());
mb_internal_encoding(CHARSET);

require './function/autoload.php';
require './function/error.php';
require './function/dump.php';

//system\config::addConfig('webname', 'phpnotes');

system\session::startSession();

$router = new system\router();

$controller = $router->getcontroller();
$templatefile = $router->gettemplatefile();
$model = $router->getmodel();
$app = $router->getapp();
$appaction = $router->getappaction();
$appparams = $router->getappparams();
$commonview = 'application\commonview';

//dump($router->getmodel());

$startapp = new $controller(new $model, $appparams, $app, $appaction);

$view = new $commonview($templatefile, $startapp->getappdata($appaction));
$view->render();
